package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.*;
import com.macro.mall.model.BmsNarratorThemeApplicant;
import com.macro.mall.portal.service.BmsNarratorThemeApplicantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@Api(tags = "BmsNarratorThemeApplicantController")
@Tag(name = "BmsNarratorThemeApplicantController", description = "讲解项目-主题-预约记录")
@RequestMapping("/narratorThemeApplicant")
public class BmsNarratorThemeApplicantController {

    @Autowired
    private BmsNarratorThemeApplicantService bmsNarratorThemeApplicantService;

    @ApiOperation("分页查询讲解项目-主题-预约记录")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsNarratorThemeApplicant>> getList(@RequestBody BmsNarratorThemeApplicantParam bmsNarratorThemeApplicantParam) {
        List<BmsNarratorThemeApplicant> bmsNarratorThemeApplicantList = bmsNarratorThemeApplicantService.getList(bmsNarratorThemeApplicantParam);
        return CommonResult.success(CommonPage.restPage(bmsNarratorThemeApplicantList));
    }

    @ApiOperation("根据id获取讲解项目-主题-预约记录信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsNarratorThemeApplicantDetail> getItem(@PathVariable Long id) {
        BmsNarratorThemeApplicantDetail bmsNarratorThemeApplicantDetail = bmsNarratorThemeApplicantService.getItem(id);
        return CommonResult.success(bmsNarratorThemeApplicantDetail);
    }

    @ApiOperation("活动预约报名")
    @RequestMapping(value = "/activitiesRegistration", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<String> reservationRegistration(@RequestBody ActivitiesRegistrationParam activitiesRegistrationParam) {
        ActivitiesRegistrationResult activitiesRegistrationResult = bmsNarratorThemeApplicantService.activitiesRegistration(activitiesRegistrationParam);
        if (activitiesRegistrationResult.getCode().equals("500")) {
            return CommonResult.failed(activitiesRegistrationResult.getMessage());
        }
        return CommonResult.success(activitiesRegistrationResult.getMessage());
    }

    @ApiOperation("活动预约报名")
    @RequestMapping(value = "/activitiesCancel", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<String> activitiesCancel(@RequestBody ActivitiesRegistrationParam activitiesRegistrationParam) {
        ActivitiesRegistrationResult activitiesRegistrationResult = bmsNarratorThemeApplicantService.activitiesCancel(activitiesRegistrationParam);
        if (activitiesRegistrationResult.getCode().equals("500")) {
            return CommonResult.failed(activitiesRegistrationResult.getMessage());
        }
        return CommonResult.success(activitiesRegistrationResult.getMessage());
    }

}
